package com.qnvip.sbd.service.impl;

import com.qnvip.sbd.dao.Assembler;
import com.qnvip.sbd.mybatis.util.UpdateMap;
import com.qnvip.sbd.service.BaseService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

@Service("baseService")
public class BaseServiceImpl implements BaseService {

	@Autowired
	private Assembler assembler;

	@Override
	public Object insert(Object object) {
		assembler.insert(object);
		return object;
	}

	@Override
	public void insertNoGeneratedId(Object object) {
		assembler.insertNoGeneratedId(object);
	}

	@Override
	public Integer delete(Object object) {
		return assembler.delete(object);
	}

	@Override
	public Integer count(Object condition, String otherCondition) {
		return assembler.count(condition, otherCondition);
	}

	@Override
	public Double sum(Object condition, String targetColumn, String otherCondition) {
		return assembler.sum(condition, targetColumn, otherCondition);
	}

	@Override
	public Integer update(UpdateMap updateMap) {
		return assembler.updateByUpdateMap(updateMap);
	}

    @Override
    public void updateByUpdateMap(UpdateMap... updateMap) {
        for (UpdateMap um : updateMap) {
            assembler.updateByUpdateMap(um);
        }
    }
}
